<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>宿舍楼施工工期横道图</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <div class="container-fluid">
        <header class="bg-primary text-white p-3 mb-4">
            <h1 class="h3 mb-0"><i class="fas fa-building"></i> 宿舍楼施工工期横道图</h1>
        </header>

        <div class="row">
            <!-- 左侧树形结构 -->
            <div class="col-md-3">
                <div class="card">
                    <div class="card-header">
                        <h5 class="mb-0">项目结构</h5>
                    </div>
                    <div class="card-body">
                        <div id="projectTree" class="tree-view">
                            <!-- 动态生成树形结构 -->
                        </div>
                    </div>
                </div>
            </div>

            <!-- 右侧甘特图区域 -->
            <div class="col-md-9">
                <div class="card">
                    <div class="card-header d-flex justify-content-between align-items-center">
                        <h5 class="mb-0">施工进度甘特图</h5>
                        <div class="btn-group">
                            <button class="btn btn-sm btn-outline-primary" onclick="exportToPNG()">
                                <i class="fas fa-image"></i> 导出PNG
                            </button>
                            <button class="btn btn-sm btn-outline-primary" onclick="exportToPDF()">
                                <i class="fas fa-file-pdf"></i> 导出PDF
                            </button>
                            <button class="btn btn-sm btn-success" onclick="saveData()">
                                <i class="fas fa-save"></i> 保存
                            </button>
                            <button class="btn btn-sm btn-secondary" onclick="undoChange()">
                                <i class="fas fa-undo"></i> 撤销
                            </button>
                        </div>
                    </div>
                    <div class="card-body">
                        <canvas id="ganttChart" width="800" height="400"></canvas>
                    </div>
                </div>
            </div>
        </div>

        <!-- 编辑模态框 -->
        <div class="modal fade" id="editModal" tabindex="-1">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">编辑工期</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                    </div>
                    <div class="modal-body">
                        <form id="editForm">
                            <div class="mb-3">
                                <label class="form-label">工序名称</label>
                                <input type="text" class="form-control" id="taskName" readonly>
                            </div>
                            <div class="mb-3">
                                <label class="form-label">开始日期</label>
                                <input type="date" class="form-control" id="startDate">
                            </div>
                            <div class="mb-3">
                                <label class="form-label">结束日期</label>
                                <input type="date" class="form-control" id="endDate">
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" onclick="updateTask()">保存更改</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.3.2/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/Chart.js/4.4.0/chart.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
    <script src="script.js"></script>
</body>
</html>